<template>
<div>
    <el-card style="margin:0 0 10px 0;" v-show="cookiesObj.roleCode == 'Admin'">
        <el-button @click="toSelectSchool" type="primary">选择学校</el-button>
       
        <el-tag closable v-if="cookiesObj.schoolName" @close='removeSchool'> {{cookiesObj.schoolName | schoolName}} </el-tag>
    </el-card>
    <el-card>
        <div class="bigDiv" >
          <div class="searchDivCss" style="display: flex; flex-wrap: wrap;" >
            <div style="margin-bottom: 18px;" >
              <span class="smallLowerCss" >学生姓名</span>
              <input type="text" v-model="conditionData.nameData" />
            </div>
            <div>
              <span>年级</span>
              <el-select v-model="conditionData.gradeIdVla" @change="gradeChange" placeholder="请选择" class="elSelect smallLowerCss" style="margin-right: 0;" >
                <el-option value='' label='全部'></el-option>
                <el-option
                  v-for="(val, index) in gradeIdData"
                  :key="index"
                  :label="val.name"
                  :value="val.id">
                </el-option>
              </el-select>
            </div>
            <div style="margin-bottom: 18px;" >
              <span>班级</span>
              <el-select v-model="conditionData.classData" placeholder="请先选择" class="elSelect" style="margin-right: 0;" >
                <el-option value='' label='全部'></el-option>
                <el-option
                  v-for="(val, index) in classDataArr"
                  :key="index"
                  :label="val.grade.name + val.name"
                  :value="val.id">
                </el-option>
              </el-select>
            </div>
            <div style="margin-bottom: 18px;" >
              <span>学籍号</span>
              <input type="text" v-model="conditionData.numData" />
            </div>
            <div style="margin-bottom: 18px;" >
              <span>学段</span>
              <el-select v-model="conditionData.periodData" placeholder="请选择" @change="periodChange" class="elSelect" style="margin-right: 0;" >
                <el-option value='' label='全部'></el-option>
                <el-option
                  v-for="item in periodDataArr"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </div>
            <div style="margin-bottom: 18px;" >
              <span>学级</span>
              <el-select v-model="conditionData.sessionData" placeholder="请选择" class="elSelect" style="margin-right: 0;" >
                <el-option value='' label='全部'></el-option>
                <el-option
                  v-for="item in sessionDataArr"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </div>
            <div style="margin-bottom: 18px;" >
              <span>学籍状态</span>
              <el-select v-model="conditionData.stateData" placeholder="请选择" style="width: 125px; " >
                <el-option value='99' label='全部'></el-option>
                <el-option
                  v-for="(val, index) in learningState" v-show="val.id != 6"
                  :key="index"
                  :label="val.name"
                  :value="val.id">
                </el-option>
              </el-select>
            </div>

            <div style="margin-bottom: 18px;" >
              <span>证件号</span>
              <el-input v-model="conditionData.IdNumber" style="width: 125px; "></el-input>
            </div>

            <el-button type="primary" style="height: 30px;" @click="queryClick" >查询</el-button>
          </div>
          <div class="functionDiv" >
            <el-button type="primary" @click="newlyAddedClick"  style="margin-left: 30px;" >新增</el-button>
            <el-button type="primary"  v-show="cookiesObj.roleCode == 'SchoolAdmin'">
                  <a style="color: #fff" href="static/template/studentTemplate.xlsx" download="学生模板">下载学生模板</a>
            </el-button>
            <!-- <el-button type="primary" style="position: relative">
                <input ref="inputFile" style="opacity:0; position: absolute;width:100%; height:100%;left:0;top:0" type="file" @change="uploadFile($event)">
              批量导入
            </el-button> -->

            <el-button type="primary" @click="exportClick" >导出excel</el-button>
            <el-button type="primary" v-show="cookiesObj.roleCode == 'SchoolAdmin'">
                <a style="color: #fff" :href="busiUrl + '/face/index.html?schoolId=' + cookiesObj.schoolId" target="_blank">人脸信息采集{{cookiesObj.schoolName}}</a>
            </el-button>
          
            <importStudent class="import-p" v-show="cookiesObj.roleCode == 'SchoolAdmin'"></importStudent>
          </div>

          <div class="listCss" >
            <el-table
              border
              :data="studentDataArr"
             >
              <el-table-column
                :show-overflow-tooltip="true"
                align='center'
                prop="schoolName"
                label="学校"
               >
              </el-table-column>
              <el-table-column
                :show-overflow-tooltip="true"
                align='center'
                prop="name"
                label="姓名"
                width="120">
              </el-table-column>
              <el-table-column
                align='center'
                label="性别"
                width="80">
                <template slot-scope="scope" >
                  <span v-if="!scope.row.gender" style="margin: 0;" > 女 </span>
                  <span v-else style="margin: 0;" >男</span>
                </template>
              </el-table-column>
              <el-table-column
                :show-overflow-tooltip="true"
                align='center'
                prop="loginName"
                label="登录名"
                width="150">
              </el-table-column>
              <el-table-column
              align='center'
                prop="studentCode"
                label="学籍号"
                width="200">
              </el-table-column>
              <el-table-column
              align='center'
                prop="idNumber"
                label="证件号"
                width="200">
              </el-table-column>
              <el-table-column
              align='center'
                :show-overflow-tooltip="true"
                prop="periodName"
                label="学级"
                width="100">
              </el-table-column>
              <el-table-column
              align='center'
              :show-overflow-tooltip="true"
              label="班级"
              width="100">
                <template slot-scope="scope" >
                  {{scope.row.gradeName}}{{scope.row.className}}
                </template>
              </el-table-column>
              <el-table-column
              align='center'
                label="学籍状态"
                width="100">
                  <template slot-scope="scope">
                    <div v-for="(val, index) in  learningState" :key="index" >
                      <span v-if="scope.row.status == val.id" style="margin: 0;" > {{val.name}} </span>
                    </div>
                  </template>
              </el-table-column>
              <el-table-column label="操作" fixed="right" width="300" align='center'>
                <div slot-scope="scope" style="width:230px;margin:0 auto;text-align:left;">
                 
                  <el-button type="primary"  @click="editClick(scope.row)" >编辑</el-button>
                  <el-button type="danger"  @click=" deleteButtonClick(scope.row, 1)" >删除</el-button>
                  <el-button type="primary" v-if="scope.row.status != 7"  @click="deleteButtonClick(scope.row, 2)" >学籍变动</el-button>
                  
                </div>
              </el-table-column>
            </el-table>
          </div>
        
          <el-pagination
            style="margin-top: 20px; text-align: right; "
            @current-change="pageChange"
            @size-change='sizeChange'
            :current-page="pagingData.pageNum"
           
            :page-size="pagingData.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="pagingData.pageAllNum">
          </el-pagination>
        </div>
        <!-- 编辑新增功能弹窗  —————————————————————————————————————————————————— -->
        <edit @changeBigPopup="bigPopupClick" :bigPopup="bigPopup" ></edit>
        <!-- 删除功能弹窗—————————————————————————————————————————————————— -->
        <el-dialog
          :title="'删除'"
          :visible.sync="dialogVisible"
          width="30%">
          <div class="deletePopUps" >
            <span style="margin-bottom: 10px; font-size: 16px; " >确定删除 <span style="color: red;" >{{deletePersonalData.name}}</span>   吗？</span>
          </div>
          <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="deleteButtonClicks(1)" >确 定</el-button>
          </span>
        </el-dialog>
         <!-- 学籍变动功能弹窗—————————————————————————————————————————————————— -->
         <el-dialog
           title="学籍变动"
           :visible.sync="dialogVisibleVice"
           :before-close="changeClosure"
           width="30%">
           <div class="deletePopUps" >
             <span style="margin-bottom: 10px;" >变动类型：</span>
             <el-select v-model="changeSelectionVal" @change="studentStatusChange" placeholder="请选择" style="width: 150px;" >
               <el-option
                 v-for="(val, index) in allTypeChange"
                 :key="index"
                 :label="val.name"
                 :value="val.id">
               </el-option>
             </el-select>
             <!-- 分班 && 转班—————————————————————————————————————————————————— -->
             <div class="transformationDiv" v-if="changeSelectionVal == 1 || changeSelectionVal == 2" >
               <span  style="margin: 20px 0 10px 0;" >新班级：</span>
               <el-select v-model="changeStudyData.classId" placeholder="请选择" style="width: 150px;" >
                 <el-option
                   v-for="(val, index) in gradeChangeArr.classChangArr"
                   :key="index"
                   :label="val.grade.name + val.name"
                   :value="val.id">
                 </el-option>
               </el-select>
               <span  style="margin: 20px 0 10px 0;" >备注：</span>
               <input type="text" v-model="changeStudyData.reason" />
             </div>
             <!-- 转学—————————————————————————————————————————————————— -->
             <div class="transformationDiv" v-if="changeSelectionVal == 3" >
               <span  style="margin: 20px 0 10px 0;" >转学至：</span>
               <input type="text" v-model="changeStudyData.target" />
               <span  style="margin: 20px 0 10px 0;" >备注：</span>
               <input type="text" v-model="changeStudyData.reason" />
             </div>
             <!-- 退学 && 休学 && 开除—————————————————————————————————————————————————— -->
             <div class="transformationDiv" v-if="changeSelectionVal == 4 || changeSelectionVal == 5 || changeSelectionVal == 6 " >
               <span  style="margin: 20px 0 10px 0;" >原因：</span>
               <input type="text" v-model="changeStudyData.reason" />
             </div>
           </div>
           <!-- 跳级 && 留级 && 复学—————————————————————————————————————————————————— -->
           <div class="transformationDiv" v-if="changeSelectionVal == 7 || changeSelectionVal == 8 || changeSelectionVal == 9" >
             <span  style="margin: 20px 0 10px 0;" v-if="changeSelectionVal == 7" >升至学段：</span>
             <span  style="margin: 20px 0 10px 0;" v-if="changeSelectionVal == 8" >留至学段：</span>
             <span  style="margin: 20px 0 10px 0;" v-if="changeSelectionVal == 9" >复至学段：</span>
             <el-select v-model="changeStudyData.stageId" @change="learningSectionChange" placeholder="请选择"  >
               <el-option
                 v-for="(val, index) in learningSectionDataArr"
                 :key="index"
                 :label="val.name"
                 :value="val.id">
               </el-option>
             </el-select>
             <span  style="margin: 20px 0 10px 0;" v-if="changeSelectionVal == 7" >升至学级：</span>
             <span  style="margin: 20px 0 10px 0;" v-if="changeSelectionVal == 8" >留至学级：</span>
             <span  style="margin: 20px 0 10px 0;" v-if="changeSelectionVal == 9" >复至学级：</span>
             <el-select v-model="changeStudyData.periodId" @change="repeatClick" placeholder="请选择"  >
               <el-option
                 v-for="(val, index) in gradeChangeArr.stageDataChangArr"
                 :key="index"
                 :label="val.name"
                 :value="val.id">
               </el-option>
             </el-select>
             <span  style="margin: 20px 0 10px 0;" v-if="changeSelectionVal == 7" >升至班级：</span>
             <span  style="margin: 20px 0 10px 0;" v-if="changeSelectionVal == 8" >留至班级：</span>
             <span  style="margin: 20px 0 10px 0;" v-if="changeSelectionVal == 9" >复至班级：</span>
             <el-select v-model="changeStudyData.classId" placeholder="请选择"  >
               <el-option
                 v-for="(val, index) in gradeChangeArr.classDataChangArr"
                 :key="index"
                 :label="val.grade.name + val.name"
                 :value="val.id">
               </el-option>
             </el-select>
             <span  style="margin: 20px 0 10px 0;" >备注：</span>
             <input type="text" v-model="changeStudyData.reason" class="inputs" />
           </div>
           <!-- ———————————————————————————————————————————————————————————————————— -->
           <span slot="footer" class="dialog-footer">
             <el-button @click="changeClosure">取 消</el-button>
             <el-button type="primary"  @click="deleteButtonClicks(2)" >确 定</el-button>
           </span>
         </el-dialog>
        <!-- <div class="deletePopUps" ></div> -->
    </el-card>

      <selectSchool :dialogVisible="selectSchoolVisible"
        @close='selectSchoolVisible = false'
        @confirm='init'
      ></selectSchool>
  </div>
</template>
<script>
import { mapActions, mapState, mapGetters, mapMutations } from 'vuex'
import {importStudentData, readStudent} from '@/util/map'
import selectSchool from '@/components/selectSchool'
import edit from './editAdd'
import COS from '@/util/COS'
import {baseUrl, busiUrl} from '@/config/config'
import importStudent from '@/components/import/importStudent'
export default {
   components: {
    edit, importStudent, selectSchool
  },
  computed: {
    ...mapState({
      cookiesObj: state => state.common.cookiesObj
    }),
    schoolId () {
      return this.$store.state.common.cookiesObj.schoolId
    },
    schoolName () {
      return this.$store.state.common.cookiesObj.schoolName
    }
  },
  data () {
    return {
      busiUrl: busiUrl,
      // 学籍详情切换标识
      details: false,
      // 删除 && 学籍变动学生的资料 （暂存）
      deletePersonalData: '',
      // 新增，编辑框弹窗标识  && 记录用户是新增还是编辑弹出的窗
      bigPopup: false,
      // 控制删除的弹窗
      dialogVisible: false,
      // 控制学籍变动的弹窗
      dialogVisibleVice: false,
      // 全部学生以及信息数组
      studentDataArr: [],
      // 学生条件搜索
      conditionData: {
        nameData: '',
        classData: '',
        numData: '',
        sessionData: '',
        stateData: '99',
        gradeIdVla: '',
        // 学段（用于筛选）
        periodData: '',
        IdNumber: ''
      },
      // 筛选模块放学段数组
      periodDataArr: [],
      // 年级数组
      gradeIdData: [],
      // 班级数组
      classDataArr: [],
      // 学级数组
      sessionDataArr: [],
      // 学段数组
      learningSectionDataArr: [],
      // 学级变动类型下拉框用户选中的值
      changeSelectionVal: 1,
      // 学籍变动班级使用数组 classChangArr: 分班，转班,  classDataChangArr: 复学,转学,留级
      gradeChangeArr: {
        classChangArr: [],
        classDataChangArr: [],
        stageDataChangArr: []
      },
      // 学籍变动弹出框存放内容
      changeStudyData: {
        reason: '',
        target: '',
        stageId: '',
        classId: '',
        periodId: ''
      },
      // 学籍变动中所有变动类型
      allTypeChange: [
        {id: 1, name: '分班'}, {id: 2, name: '转班'}, {id: 3, name: '转学'}, {id: 4, name: '退学'},
        {id: 5, name: '休学'}, {id: 6, name: '开除'}, {id: 7, name: '跳级'}, {id: 8, name: '留级'}, {id: 9, name: '复学'}
      ],
      // 学籍状态
      learningState: [
        {id: 1, name: '在籍'}, {id: 2, name: '毕业'}, {id: 3, name: '休学'},
        {id: 4, name: '退学'}, {id: 5, name: '开除'}, {id: 6, name: '转学'}, {id: 7, name: '转学'}
      ],
      // 性别数组
      genderDataArr: [
        {id: 1, name: '男', data: true}, {id: 2, name: '女', data: false}
      ],
      // 分页  当前页，每页条数，总条数
      pagingData: {
        pageNum: 1,
        pageSize: 10,
        pageAllNum: 0
      },
      value: '',

      selectSchoolVisible: false
    }
  },
 
  methods: {
    ...mapActions({
      getStudentList: 'studentList/getStudentList',
      getSingleStudent: 'studentList/getSingleStudent',
      addStudentApi: 'studentList/addStudentApi',
      addLearnApi: 'studentList/addLearnApi',
      deleteStudentsApi: 'studentList/deleteStudentsApi',
      studentChangeApi: 'studentList/studentChangeApi',
      toUpdateApi: 'studentList/toUpdateApi',
      newStudentsApi: 'studentList/newStudentsApi',
      allSectionsApi: 'studentList/allSectionsApi',
      enumerationApi: 'studentList/enumerationApi',
      monitorApi: 'studentList/monitorApi',
      getAllGradeApi: 'studentList/getAllGradeApi'
    }),
    ...mapMutations({
      individualStudentMut: 'studentList/individualStudentMut',
      documentTypeDataArrMut: 'studentList/documentTypeDataArrMut',
      nationDataArrMut: 'studentList/nationDataArrMut',
      healthyDataArrMut: 'studentList/healthyDataArrMut',
      entranceDataArrMut: 'studentList/entranceDataArrMut',
      residenceTypeDataArrMut: 'studentList/residenceTypeDataArrMut',
      politicalOutlookDataArrMut: 'studentList/politicalOutlookDataArrMut',
      admissionModeDataArrMut: 'studentList/admissionModeDataArrMut',
      modeOfStudyDataArrMut: 'studentList/modeOfStudyDataArrMut',
      disabilityTypeDataArrMut: 'studentList/disabilityTypeDataArrMut',
      onDutyDataArrMut: 'studentList/onDutyDataArrMut',
      modeOfTransportationDataArrMut: 'studentList/modeOfTransportationDataArrMut',
      relativesDataArrMut: 'studentList/relativesDataArrMut',
      oCCompatriotsDataArrMut: 'studentList/oCCompatriotsDataArrMut'
    }),
    async uploadFile () {
      var fileList = this.$refs.inputFile.files
      for (let file of fileList) {
          var list = await readStudent({file: file, fileId: Math.random() + ''})
           try {
              while (true) {
                  var temp = list.splice(0, 20)
                  if (temp.length > 0) {
                      await importStudentData({list: temp, schoolId: this.schoolId})
                  } else {
                      break
                  }
              }
          } catch (error) {
              console.log(error)
              this.$message.error(error.data.error.message)
          }
      }
      this.$refs.inputFile.value = ''
    },
    // 点击新增按钮触发事件
    newlyAddedClick () {
      if (!this.schoolId) {
          this.$message.error('请选择学校')
          return
      }
      this.individualStudentMut('')
      this.bigPopup = true
    },
    // 点击编辑触发事件
    editClick (e) {
      this.getSingleStudent(e.id).then(res => {
        this.individualStudentMut(res)
        this.bigPopup = true
      })
    },
    // 学籍变动改变状态触发事件
    studentStatusChange (e) {
      // Object.assign(this.$data.gradeChangeArr, this.$options.data().gradeChangeArr)
      this.gradeChangeArr.classDataChangArr = []
      this.gradeChangeArr.stageDataChangArr = []
      Object.assign(this.$data.changeStudyData, this.$options.data().changeStudyData)
      console.log(e)
    },
    // 学籍变动弹窗关闭触发事件
    changeClosure () {
      this.dialogVisibleVice = false
      Object.assign(this.$data.gradeChangeArr, this.$options.data().gradeChangeArr)
      Object.assign(this.$data.changeStudyData, this.$options.data().changeStudyData)
      this.changeSelectionVal = 1
    },
    // 留级，复学，跳级中学段变动触发事件
    learningSectionChange (e) {
      let getLearn = {
				id: this.schoolId,
				data: {
					Sorting: 'name DESC',
					StageId: e
				}
      }
      this.addLearnApi(getLearn).then(res => {
        this.gradeChangeArr.stageDataChangArr = res
        console.log(res)
      })
    },
    //  留级，复学，跳级中学级变动触发事件
    repeatClick (e) {
      let allClass = {
        id: this.cookiesObj.schoolId,
        data: {
          Sorting: 'orderNum',
          PoerdId: e
        }
      }
      this.addStudentApi(allClass).then(res => {
       this.gradeChangeArr.classDataChangArr = res
      })
    },
    // 删除 && 学籍变动  按钮触发事件
    deleteButtonClick (e, num) {
      this.deletePersonalData = e
      this.aloneGetClass(this.deletePersonalData.gradeId)
      num == 1 ? this.dialogVisible = true : this.dialogVisibleVice = true
      console.log(this.sessionDataArr)
    },
    deleteButtonClicks (e) {
      if (e == 1) {
        this.deleteStudentsApi(this.deletePersonalData.id).then(res => {
        this.allStudentData(this.conditionData.nameData, this.conditionData.classData, this.conditionData.numData, this.conditionData.sessionData, this.conditionData.stateData, this.conditionData.gradeIdVla)
        this.deletePersonalData = ''
        this.dialogVisible = false
        this.$message({
            message: '删除成功',
            type: 'success'
          })
        })
      } else {
        if (this.changeSelectionVal == 1 || this.changeSelectionVal == 2) {
          if (!this.changeStudyData.classId || !this.changeStudyData.reason) {
            this.$message.error('请完整填写变动信息')
            return
          }
        }

        if (this.changeSelectionVal == 3) {
          if (!this.changeStudyData.target || !this.changeStudyData.reason) {
            this.$message.error('请完整填写转学信息')
            return
          }
        }

        if (this.changeSelectionVal == 4 || this.changeSelectionVal == 5 || this.changeSelectionVal == 6) {
          if (!this.changeStudyData.reason) {
            this.$message.error('请完整填写变动信息')
            return
          }
        }

        if (this.changeSelectionVal == 7 || this.changeSelectionVal == 8 || this.changeSelectionVal == 9) {
          if (!this.changeStudyData.reason || !this.changeStudyData.stageId || !this.changeStudyData.periodId || !this.changeStudyData.classId) {
            this.$message.error('请完整填写变动信息')
            return
          }
        }

        let params = {
          id: this.deletePersonalData.loginUserId,
          body: {
            type: this.changeSelectionVal,
            target: this.changeStudyData.target,
            stageId: this.changeStudyData.stageId,
            classId: this.changeStudyData.classId,
            periodId: this.changeStudyData.periodId,
            reason: this.changeStudyData.reason
          }
        }
        this.studentChangeApi(params).then(res => {
          this.allStudentData(this.conditionData.nameData, this.conditionData.classData, this.conditionData.numData, this.conditionData.sessionData, this.conditionData.stateData, this.conditionData.gradeIdVla)
          this.$message({
            message: '变动成功',
            type: 'success'
          })
          this.changeSelectionVal = 1
          Object.assign(this.$data.changeStudyData, this.$options.data().changeStudyData)
          this.dialogVisibleVice = false
          this.deletePersonalData = ''
        })
      }
    },
    // 查询条件年级变化触发事件
    gradeChange (e) {
      console.log(e)
      this.conditionData.classData = ''
      let allClass = {
        id: this.cookiesObj.schoolId,
        data: {
          Sorting: 'orderNum',
          GradeId: e
        }
      }
      if (!e) {
        this.classDataArr = []
      } else {
        this.addStudentApi(allClass).then(res => {
          this.classDataArr = res
        })
      }
    },
    // 筛选条件，学段值改变触发事件
    periodChange (e) {
      let getLearn = {
        id: this.schoolId,
        data: {
        	Sorting: 'name DESC',
        	StageId: e
        }
      }
      if (!e) {
        this.sessionDataArr = []
      } else {
        this.addLearnApi(getLearn).then(res => {
          this.sessionDataArr = res
        })
      }
    },
    // 条件查询按钮触发事件
    queryClick () {
      // console.log(this.conditionData.classData)
      this.pagingData.pageNum = 1
      this.allStudentData(this.conditionData.nameData, this.conditionData.classData, this.conditionData.numData, this.conditionData.sessionData, this.conditionData.stateData, this.conditionData.gradeIdVla)
    },
    // 导出按钮触发事件
    exportClick () {
      if (!this.schoolId) {
          this.$message.error('请选择学校')
          return
      }
      window.open(baseUrl + '/bdc/api/app/student/export?schoolId=' + this.cookiesObj.schoolId + '&studentName=' + this.conditionData.nameData + '&classId=' + this.conditionData.classData + '&StudentCode=' + this.conditionData.numData + '&PeriodName=' + this.conditionData.sessionData + '&Status=' + this.conditionData.stateData)
      this.$message({
        message: '下载中...',
        type: 'success'
      })
    },
    sizeChange (e) {
      this.pagingData.pageSize = e
      this.allStudentData()
    },
    // 页码变动触发事件
    pageChange (e) {
      this.pagingData.pageNum = e
      this.allStudentData(this.conditionData.nameData, this.conditionData.classData, this.conditionData.numData, this.conditionData.sessionData, this.conditionData.stateData, this.conditionData.gradeIdVla)
    },
    // 子组件发过来关闭弹窗事件
    bigPopupClick (e) {
      this.bigPopup = e
      this.allStudentData(this.conditionData.nameData, this.conditionData.classData, this.conditionData.numData, this.conditionData.sessionData, this.conditionData.stateData, this.conditionData.gradeIdVla)
    },
    // 获取  全部学生，筛选学生请求封装
    allStudentData (name, classIds, number, session, state, gradeId) {
      if (!state) {
        state = 99
      }
      
      // 全部 & 条件 获取学生
      let params = {
        schoolId: this.cookiesObj.schoolId,
        studentName: this.conditionData.nameData,
        classId: this.conditionData.classData,
        StudentCode: this.conditionData.numData,
        PeriodId: this.conditionData.sessionData,
        Status: this.conditionData.stateData, 
        gradeId: this.conditionData.gradeIdVla,
        IdNumber: this.conditionData.IdNumber,
        PageNum: this.pagingData.pageNum,
        PageSize: this.pagingData.pageSize,
        includeDeleted: true
      }
      for (let key in params) {
        if (!params[key]) {
          delete params[key]
        }
      }
      this.getStudentList(params).then(res => {
        this.studentDataArr = res.data.items
        this.pagingData.pageAllNum = res.data.totalCount
      })
    },
    getGradeList () {
         // 获取全部年级
        let getGrade = {
          Sorting: 'orderNum',
          schoolId: this.schoolId
        }
        this.getAllGradeApi(getGrade).then(res => {
          this.gradeIdData = res
        })
    },
    getPeriodList () {
      // 获取全部学段
      this.allSectionsApi(this.cookiesObj.schoolId).then(res => {
        this.periodDataArr = res
        this.learningSectionDataArr = res
      })
    },
    // 获取字典枚举封装
    enumeration (type, arr) {
      let params = {
        typeCode: type
      }
      this.enumerationApi(params).then(res => {
        this[arr](res)
      })
    },
    // 单独条件获取班级请求封装
    aloneGetClass (e) {
      let allClass = {
        id: this.cookiesObj.schoolId,
        data: {
          Sorting: 'orderNum',
          GradeId: e
        }
      }

      this.addStudentApi(allClass).then(res => {
       this.gradeChangeArr.classChangArr = res
       console.log(res)
      })
    },
    toSelectSchool () {
      this.selectSchoolVisible = true
    },

    init () {
      this.clear()
      this.allStudentData()
      this.getGradeList()
      this.getPeriodList()
      this.enumeration('IdCardType', 'documentTypeDataArrMut')
      this.enumeration('Nationality', 'nationDataArrMut')
      this.enumeration('HealthStatus', 'healthyDataArrMut')
      this.enumeration('EnrolmentMode', 'entranceDataArrMut')
      this.enumeration('HouseholdRegType', 'residenceTypeDataArrMut')
      this.enumeration('PoliticalStatus', 'politicalOutlookDataArrMut')
      this.enumeration('StudentSource', 'admissionModeDataArrMut')
      this.enumeration('StudyMode', 'modeOfStudyDataArrMut')
      this.enumeration('DisabilityType', 'disabilityTypeDataArrMut')
      this.enumeration('FollowStudyType', 'onDutyDataArrMut')
      this.enumeration('TransportMode', 'modeOfTransportationDataArrMut')
      this.enumeration('FamilyRelation', 'relativesDataArrMut')
      this.enumeration('Alien', 'oCCompatriotsDataArrMut') 
    },
    removeSchool () {
       delete this.$store.state.common.cookiesObj.schoolId
       delete this.$store.state.common.cookiesObj.schoolName
       this.$store.state.common.cookiesObj = JSON.parse(JSON.stringify(this.$store.state.common.cookiesObj))
       this.init()
    },
    clear () {
      this.conditionData.gradeIdVla = ''
      this.conditionData.classData = ''
    }
  },
  mounted () {
      this.init()
  }
}
</script>

<style scoped lang="less">
.smallLowerCss {
  margin-bottom: 18px;
}

.bigDiv {
  span {
    margin: 0 10px 0 15px ;
  }
  input {
    width: 120px;
    height: 30px;
    border: 1px solid #e2e2e2;
    border-radius: 5px;
    padding-left: 10px;
  }
}

.searchDivCss {
  button {
    margin-left: 30px;
  }
}

.functionDiv {
  padding: 10px 0;
}

.text {
  color: #0362FD;
  cursor: pointer;
}

.listCss {
  min-width: 660px;
  border-top: 1px solid #C2CAD8;
  overflow-y:scroll;
}

.flex {
  display: flex;
  align-items: center;
}

.elSelect {
  width: 150px;
  margin-right: 55px;
}

.deletePopUps {
  display: flex;
  flex-direction: column;
  input {
    height: 30px;
    border: 1px solid #C1CBD0;
    border-radius: 5px;
    padding-left: 10px;
  }
}

.transformationDiv {
  display: flex;
  flex-direction: column;
}

.inputs {
  // width: 500px;
  height: 30px;
  border: 1px solid #C1CBD0;
  border-radius: 5px;
  padding-left: 10px;
}

.el-dialog__body {
  padding: 30px 40px;
}

.import-p {
  display: inline-block;
  vertical-align: top;
}

</style>
<style>
.el-table th.is-leaf, .el-table td {
  text-align: center;
}
.el-table--border th {
  background: #f6f6fd;
  font-weight: 900;
  color: #000;
}
.el-dialog__body {
  padding: 30px 40px;
}

</style>
